package com.qf.controller;

import com.qf.const1.ErrorCode;
import com.qf.exception.BusinessException;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/user2")
public class UserController2 {

    @RequestMapping("/ex1")
    @ResponseBody
    public String ex1(Integer age){

        if (age < 0){
            throw new BusinessException("年龄必须大于0", ErrorCode.AGE_LT_0);
        }
        if (age > 150){
            throw new BusinessException("年龄不可能大于150",ErrorCode.AGE_GT_150);
        }

        return "success";
    }
}
